<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/inc/taglib.jsp"%>
<div class="pageContent">
	<form method="post" action="${requestScope.record ==null ?'system/permission/insert' :'system/permission/update' }" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">

		<c:if test="${requestScope.record !=null}">
			<!-- 编辑 -->
			<input type="hidden" name="id" value="${requestScope.record.id}" />
			<input type="hidden" name="level" value="${requestScope.record.level}" />
			<c:set var="level" value="${requestScope.record.level}" />
		</c:if>


		<c:if test="${requestScope.record == null}">
			<!--新增-->
			<c:if test="${requestScope.parent.level == null}">
				<input type="hidden" name="level" value="1" />
				<c:set var="level" value="1" />
			</c:if>
			<c:if test="${requestScope.parent.level != null}">
				<input type="hidden" name="level" value="${requestScope.parent.level+1}" />
				<c:set var="level" value="${requestScope.parent.level+1}" />
			</c:if>
			<input type="hidden" name="pid" value="${requestScope.parent.id}" />
		</c:if>

		<div class="pageFormContent" layoutH="57">
			<c:if test="${requestScope.parent !=null}">
				<dl class="nowrap">
					<dt>父级名称：</dt>
					<dd>
						<input name="name" value="${requestScope.parent.name }" type="text" size="30" class="required disabled" disabled maxlength="50" />
					</dd>
				</dl>
			</c:if>
			<dl class="nowrap">
				<dt>菜单级别：</dt>
				<dd>
					<input value="${pageScope.level}" type="text" size="30" class="required disabled" disabled maxlength="50" />
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>菜单名称：</dt>
				<dd>
					<input name="name" value="${requestScope.record.name }" type="text" size="30" class="required" maxlength="50" />
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>排序：</dt>
				<dd>
					<input name="sort" value="${requestScope.record.sort }" type="text" size="30" class="required" maxlength="10" />
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>权限类型：</dt>
				<dd>
					<select class="combox" name="type" id="type" class="required">
						<option value="0" ${requestScope.record.type == 0 ? 'selected' : '' }>展示菜单</option>
						<option value="1" ${requestScope.record.type == 1 ? 'selected' : '' }>功能菜单</option>
						<option value="2" ${requestScope.record.type == 2 ? 'selected' : '' }>功能按钮</option>
					</select>
				</dd>
			</dl>
			<dl class="nowrap" id="dl_url" style="display: none;">
				<dt>url：</dt>
				<dd>
					<input id="url" name="url" value="${requestScope.record.url }" type="text" size="30" maxlength="500" />
				</dd>
			</dl>
			<dl class="nowrap" id="dl_icon">
				<dt>图标：</dt>
				<dd>
					<input name="icon" value="${requestScope.record.icon }" type="text" size="30" />
				</dd>
			</dl>
			<dl class="nowrap">
				<dt>备注：</dt>
				<dd>
					<textarea cols="45" rows="5" name="remk">${requestScope.record.remk }</textarea>
				</dd>
			</dl>
			<div class="divider"></div>
			<ul>
				<li>
					<div class="buttonActive">
						<div class="buttonContent">
							<button type="submit">保存</button>
						</div>
					</div>
				</li>
				<li>
					<div class="button">
						<div class="buttonContent">
							<button type="button" class="close">取消</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</form>
</div>
<script type="text/javascript">
	$("#type", navTab.getCurrentPanel()).change(function() {
		isHide($(this).val());
	})
	$(function() {
		var type = '${requestScope.record.type}';
		isHide(type);
	});
	function isHide(type) {
		if (type == 0) {
			$("#dl_url", navTab.getCurrentPanel()).hide();
			$("#dl_icon", navTab.getCurrentPanel()).show();
			$("#url", navTab.getCurrentPanel()).removeClass("required");
		} else if (type == 1) {
			$("#dl_url", navTab.getCurrentPanel()).show();
			$("#dl_icon", navTab.getCurrentPanel()).show();
			$("#url", navTab.getCurrentPanel()).addClass("required");
		} else if (type == 2) {
			$("#dl_url", navTab.getCurrentPanel()).show();
			$("#dl_icon", navTab.getCurrentPanel()).hide();
			$("#url", navTab.getCurrentPanel()).addClass("required");
		}
	}
</script>
